home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 43.zip / Sources C- WorkDisk V.adf / vierk.c < prev   
C/C++ Source or Header  |  1987-02-14  |  5KB  |  221 lines

  1. #include "exec/types.h"
  2. #include "graphics/gfxmacros.h"
  3. #include "intuition/intuition.h"
  4.  
  5.  
  6.  
  7. struct IntuitionBase *IntuitionBase;
  8. struct Window *NoBorder;
  9. struct GfxBase *GfxBase;
  10. struct Screen *Scrn;
  11. struct IntuiMessage *mesg;
  12. struct RastPort *r;
  13. struct ViewPort *vp;
  14.  
  15. #define MAXW  320 /* max width van window ! */
  16. #define MAXH  200 /* max height van window ! */
  17. #define HALFMAXH MAXH/2-1
  18.  
  19. struct NewScreen NewScrn = {
  20.         0, 0,           /* LeftEdge, TopEdge */
  21.         320,200,       /* Width, Height */
  22.         5,              /* Depth */
  23.         0, 1,           /* DetailPen, BlockPen */
  24.         NULL,           /* ViewModes ... value of 0 = low resolution */
  25.         CUSTOMSCREEN,   /* Type of screen */
  26.         NULL,           /* Font to be used as default for this screen */
  27.         NULL,           /* DefaultTitle for its title bar */
  28.         NULL,           /* screens user-gadgets, always NULL, ignored */
  29.         NULL };         /* address of custom bitmap for screen */
  30.  
  31. struct NewWindow NewNoBorder = {
  32.         0,              /* LeftEdge */
  33.         0,              /* TopEdge  */
  34.         MAXW, MAXH,     /* Width, Height of this window */
  35.         -1,             /* DetailPen */
  36.         -1,             /* BlockPen */
  37.         MOUSEBUTTONS,   /* IDCMP Flags */
  38.         ACTIVATE|NOCAREREFRESH|BORDERLESS|GIMMEZEROZERO|BACKDROP,
  39.                         /* Window Flags:  (see below for more info) */
  40.         NULL,           /* FirstGadget */
  41.         NULL,           /* CheckMark   */
  42.         NULL,           /* Window title */
  43.         NULL,           /* Pointer to Screen if not workbench */
  44.         NULL,           /* Pointer to BitMap if a SUPERBITMAP window */
  45.         0, 0,           /* minimum width, minimum height */
  46.         0,0,            /* maximum width, maximum height */
  47.         CUSTOMSCREEN    /* type waarin window opend */
  48.         };
  49.  
  50.  
  51. #define INTUITION_REV 0
  52. #define GRAPHICS_REV 0
  53.  
  54.  
  55.  
  56. main()
  57. {
  58.  ULONG mclass;
  59.  SHORT len,einde,i,j,k,zijde,xnul,ynul;
  60.  
  61.  
  62.  
  63.  VOID OpenALL();
  64.  
  65.  OpenALL();
  66.  
  67.  if((Scrn = (struct Screen *) OpenScreen(&NewScrn)) == 0) exit(10);
  68.  
  69.  NewNoBorder.Screen = Scrn;
  70.  
  71.  if((NoBorder = (struct Window *) OpenWindow(&NewNoBorder)) == 0) exit(20);
  72.  
  73.  /* ======geen screentitel====== */
  74.  
  75.  ShowTitle(Scrn,0);
  76.  
  77.  /* ======definitie van RPort !====== */
  78.  
  79.  r=NoBorder->RPort;
  80.  vp=ViewPortAddress(NoBorder);
  81.  
  82.  
  83.   for(i=1;i<32;i++) SetRGB4(vp,i,i%16,0,16-i%16);
  84.  
  85.   SetRGB4(vp,0,0,0,0);
  86.  
  87. /* init variabelen */
  88.  
  89.  zijde = 10;
  90.  
  91.  for(j=0;j<10;j++)
  92.  {
  93.   for(i=0;i<10;i++)
  94.   {
  95.    SetAPen(r,1+((i+j)%31));
  96.    xnul = 59;ynul = 0;
  97.    RectFill(r,xnul+zijde*i,ynul+zijde*j,xnul+zijde*(i+1),ynul+zijde*(j+1));
  98.    RectFill(r,xnul+zijde*j,ynul+zijde*i,xnul+zijde*(j+1),ynul+zijde*(i+1));
  99.  
  100.    xnul = 259;ynul = 0;
  101.    RectFill(r,xnul-zijde*(i+1),ynul+zijde*j,xnul-zijde*i,ynul+zijde*(j+1));
  102.    RectFill(r,xnul-zijde*(j+1),ynul+zijde*i,xnul-zijde*j,ynul+zijde*(i+1));
  103.    
  104.    xnul = 59;ynul = 200;
  105.    RectFill(r,xnul+zijde*i,ynul-zijde*(j+1),xnul+zijde*(i+1),ynul-zijde*j);
  106.    RectFill(r,xnul+zijde*j,ynul-zijde*(i+1),xnul+zijde*(j+1),ynul-zijde*i);
  107.  
  108.    xnul = 259;ynul = 200;
  109.    RectFill(r,xnul-zijde*(i+1),ynul-zijde*(j+1),xnul-zijde*i,ynul-zijde*j);
  110.    RectFill(r,xnul-zijde*(j+1),ynul-zijde*(i+1),xnul-zijde*j,ynul-zijde*i);
  111.   }
  112.  }
  113.  
  114.  for(k=0;k<10;k++)
  115.  {
  116.     for(j=0;j<20;j++)
  117.      {
  118.       for(i=1;i<32;i++) SetRGB4(vp,i,(i+j)%16,0,16-(i+j)%16);
  119.       Delay(1);
  120.      }
  121.      for(j=19;j>=0;j--)
  122.      {
  123.       for(i=31;i>=1;i--) SetRGB4(vp,i,(i+j)%16,0,16-(i+j)%16);
  124.       Delay(1);
  125.      }
  126.  }
  127.  
  128.  /* ======einde in stijl !====== */
  129. einde=0;
  130. while(!einde)
  131.  {
  132.   while((mesg=(struct IntuiMessage *)
  133.     GetMsg(NoBorder->UserPort))==NULL)
  134.   {
  135.  
  136.     for(j=0;j<20;j++)
  137.      {
  138.       for(i=1;i<32;i++) SetRGB4(vp,i,(i+j)%16,0,16-(i+j)%16);
  139.       Delay(1);
  140.      }
  141.      for(j=19;j>=0;j--)
  142.      {
  143.       for(i=31;i>=1;i--) SetRGB4(vp,i,(i+j)%16,0,16-(i+j)%16);
  144.       Delay(1);
  145.      }
  146.   }
  147.  
  148.   ReplyMsg(mesg);
  149.   mclass=mesg->Class;
  150.  
  151.  
  152.   if(mclass==MOUSEBUTTONS)
  153.    {
  154.      einde=1;
  155.  
  156.      SetAPen(r,0);
  157.      SetDrPt(r,0xAAAA);
  158.      for(i=0;i<160;i+=2)
  159.      {
  160.       Move(r,159-i,0);Draw(r,159-i,MAXH);
  161.       Move(r,160+i,0);Draw(r,160+i,MAXH);
  162.      }
  163.      for(i=1;i<160;i+=2)
  164.      {
  165.       Move(r,159-i,0);Draw(r,159-i,MAXH);
  166.       Move(r,160+i,0);Draw(r,160+i,MAXH);
  167.      }
  168.  
  169.      SetDrPt(r,0xffff);
  170.      for(i=0;i<160;i+=2)
  171.      {
  172.       Move(r,159-i,0);Draw(r,159-i,MAXH);
  173.       Move(r,160+i,0);Draw(r,160+i,MAXH);
  174.      }
  175.      for(i=1;i<160;i+=2)
  176.      {
  177.       Move(r,159-i,0);Draw(r,159-i,MAXH);
  178.       Move(r,160+i,0);Draw(r,160+i,MAXH);
  179.      }
  180.  
  181.      CloseWindow(NoBorder);
  182.      CloseScreen(Scrn);
  183.      CloseLibrary(GfxBase);
  184.  
  185.    }
  186.  }
  187.  
  188. /********************************** einde van main **********************/
  189.  
  190. VOID OpenALL()
  191. {
  192.  /*==Intuition==*/
  193.  
  194.  IntuitionBase=(struct IntuitionBase *)
  195.             OpenLibrary("intuition.library",INTUITION_REV);
  196.  
  197.  if(IntuitionBase==NULL)
  198.     exit(FALSE);
  199.  
  200.  /*==Graphics Library==*/
  201.  
  202.  GfxBase=(struct GfxBase *)
  203.           OpenLibrary("graphics.library",GRAPHICS_REV);
  204.  
  205.  if(GfxBase==NULL)
  206.     exit(FALSE);
  207.  
  208. }
  209.  
  210.  
  211. PrintAt(rast,x,y,s)
  212. struct RastPort *rast;
  213. int x,y;
  214. char *s;
  215. {
  216.  Move(rast,x,y);
  217.  Text(rast,s,strlen(s));
  218. }
  219.  
  220.